﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DevExpress.Xpo;
using GDIT.Base.LogHelper;
using GDIT.Base;
using GDIT.Base.PageBaseHelper;
using GDIT.BLL;
using NHibernate;
using NHibernate.Cfg;
using GDIT.Model;


namespace GDIT
{
    public partial class index : System.Web.UI.Page
    {
        //private BUsers _busers = new BUsers();
       // private ISessionFactory factoy = null;
       // private ISession session = null;
        //private static  DevExpress.Xpo.Session session = null;

        //private static Session session;
        //protected void Page_Init(object sender, EventArgs e)
        //{
        //    session = new Session(XpoDefault.DataLayer);
        //    //XpoDataSource1.Session = session;
        //}

        protected void Page_Load(object sender, EventArgs e)
        {
            
            //factoy = new Configuration().Configure().BuildSessionFactory();
            //session = factoy.OpenSession();

            //session = new Session(XpoDefault.DataLayer);
            //session.Connect();

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            //_busers.AddUsers("胡鼎文","123");
            //session = factoy.OpenSession();
            //Users user = new Users();
            //user.Username = "姚明";
            //user.Userpwd = "11号";
            //user = (Users)session.CreateQuery("from Users where UserName='2'")
            //    .UniqueResult();
            //Logger.Info(String.Format("名字是{0}", user.Username));
            //PageBase.HtmlResponseWrite(user.Username, true);
            //session.Save(user);

           
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            //IList<Users> u = session.CreateQuery("from Users where UserName='2'")
            //    .List<Users>();
           // Users user = (Users)u[0];
           // PageBase.HtmlResponseWrite(user.Username, true);
        }

        //readonly BUsers user = new BUsers(session);

        //protected void Button3_Click(object sender, EventArgs e)
        //{//登陆按钮
        //    BUsers user = new BUsers();
        //    bool result = user.IsLogin(this.TextBox1.Text.Trim(),this.TextBox2.Text.Trim());
        //    if (result == true)
        //    {
        //        Response.Write("<script langurage='javascript'>alert('登陆成功！');</script>");
        //    }
        //    else
        //    {
        //        Response.Write("<script langurage='javascript'>alert('登陆失败！');</script>");
        //    }
        //}

        //protected void Button4_Click(object sender, EventArgs e)
        //{//生成角色按钮
        //    Mtb_Roles role = new Mtb_Roles();
        //    //Mtb_Department depart = new Mtb_Department();

        //    role.RoleName = "网站管理员";
        //    Mtb_Users user = new Mtb_Users();
        //    user.UserName = "admin";
        //    user.UserPwd = "admin";
        //    Mtb_BulletinArticle a = new Mtb_BulletinArticle();
        //    a.Title = "我去";
        //    a.Contents = "巴尔加罚款的减肥了扩大设计费";
        //    user.BulletinArticles.Add(a);
        //    Mtb_CollegeInformationArticle b = new Mtb_CollegeInformationArticle();
        //    b.Title = "内建军节";
        //    b.Contents = "将疯狂大家顺口溜发动机奥斯卡两地分居";
        //    user.CollegeInformationArticles.Add(b);
        //    role.Users.Add(user);
        //    role.Save();
        //}

        //protected void Button5_Click(object sender, EventArgs e)
        //{//修改按钮

        //    try
        //    {
        //        BUsers user = new BUsers();
        //        Mtb_Users users = new Mtb_Users();
        //        users.UserName = this.TextBox1.Text.Trim();
        //        users.UserPwd = this.TextBox2.Text.Trim();
        //        bool result = user.UpdateUserData(users);
        //        if (!result)
        //        {
        //            Response.Write("<script langurage='javascript'>alert('更新失败');</script>");
        //        }
        //        else
        //        {
        //            Response.Write("<script langurage='javascript'>alert('更新成功！');</script>");
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        Response.Write("<script langurage='javascript'>alert('"+ex.Message.ToString()+"');</script>");
        //    }
        //}


    }
}